﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Web;



namespace NetCore
{

    public enum ProviderType
    {
        SqlServer = 1,
        Oracle = 2,
        MySql = 3,
        MsSqlCe = 4,
        SQLite = 5,
        PostgreSQL = 6,
        JetDriver = 7,
        DB2 = 8,
        Oledb = 9,
        ODBC = 10,
        Access = 11,
        /// <summary>
        /// 其他类型
        /// </summary>
        Default = 99
    }
    /// <summary>
    /// 静态类
    /// </summary>
    public partial class ApplicationEnvironments
    {
       
        public static ProviderType ProviderType
        {
            get;
            set;
        }

    
        static IApplicationSession _session;
        /// <summary>
        /// 获取或设置默认的当前用户的登录的信息
        /// </summary>
        /// <returns></returns>
        public static IApplicationSession DefaultSession
        {
            get
            {
                return _session;
            }
            set
            {
                _session = value;
            }
        }

        public static SiteConfig Site { get; set; }
        /// <summary>
        /// 如果为windows程序，那么自动更新的路径
        /// </summary>
        public static string AutoUpdaterPath = "";
       
        /// <summary>
        /// 产品的项目名
        /// </summary>
        public static string ApplicationName {
            get
            {
                return Site.ApplicationName;
            }
        }
        /// <summary>
        /// 版本
        /// </summary>
        public static string Version {
            get {
                return Site.Version;
            }
        }

        /// <summary>
        /// 文件存储路径
        /// </summary>
        public static string BaseDirectory
        {
            get {
                return Site.BaseDirectory;
            }
        }
        public static string DefaultDirectory
        {
            get
            {
                return Site.DefaultDirectory;
            }
        }
        /// <summary>
        /// 根目录
        /// </summary>
        public static string RootPath
        {
            get
            {
                return BaseDirectory + Site.ConfigFile.rootPath;
            }
        }
        /// <summary>
        /// 临时文件
        /// </summary>
        public static string TempPath
        {
            get
            {
                return Site.ConfigFile.tempPath+DefaultSession.UserId+"/";
            }
        }
       
        ///// <summary>
        ///// 网站域名如.haopoo.com
        ///// </summary>
        //public static string Domain
        //{
        //    get
        //    {
        //        string localpath = Current.Request.Url.LocalPath;
        //        if (!string.IsNullOrEmpty(localpath) && !localpath.Equals("/") && !localpath.Equals("//"))
        //        {
        //            return Current.Request.Url.ToString().Replace(localpath + Current.Request.Url.Query, "");
        //        }
        //        return Current.Request.Url.ToString();

        //    }
        //}

        /// <summary>
        /// 存放当前信息的cookie关键字
        /// </summary>
        public static string CookieKeys = "whlrom";

        /// <summary>
        ///  是否是web程序
        /// </summary>
        public static bool IsWeb
        {
            get
            {
                return Site.IsWeb;
            }
           
        }
        public static int CommandTimeout = 30000;

        public static bool IsDevelopment { get; set; }
        //private static readonly object m_locked = new object();
        //private const string m_cache_nityContainer = "m_cache_nityContainer";
        //public static UnityContainer GetContainer()
        //{
        //    //return CacheHelper.Instance.Get<UnityContainer>("m_cache_nityContainer", () =>
        //    //   {
        //    lock (m_locked)
        //    {
        //        var container = new UnityContainer();
        //        string assemblyName = ConfigurationHelper.GetSetting("EntityDLL");
        //        string[] arrAssemblyName = assemblyName.Split(new char[] { ';', ',' });
        //        foreach (var item in arrAssemblyName)
        //        {
        //            var types = System.Reflection.Assembly.Load(item.Replace("Model", "BLL")).GetTypes();
        //            if (types != null)
        //            {
        //                foreach (var t in types)
        //                {
        //                    if (t.GetInterface("IDependencyRegisterType") != null)
        //                    {
        //                        ((IDependencyRegisterType)Activator.CreateInstance(t)).CreateContainer(ref container);
        //                        break;
        //                    }
        //                }
        //            }

        //        }
        //        return container;
        //    }
        //    // });
        //}

    }

}
